#include <iostream>
#include <QFile>
#include <QDebug>

#include "auditapi.h"
#include "auditcryptogram.h"
#include "auditcore.h"
void test_apiStdDecryptionFile(void) {
    qDebug() << "apiStdEncryptionFile ret :"
             << apiStdDecryptionFile("G:/License_x64.txt",0);
    return ;
}

void test_apiStdEncryptionFile(void) {
    qDebug() << "apiStdEncryptionFile ret :"
             << apiStdEncryptionFile("G:/License_x64.txt",0);
    return ;
}

void test_apiRegisterAccount(void) {
//    qDebug() << "apiRegisterAccount ret :"
//             << apiRegisterAccount("name","user","pswd");
}

void test_apiLoginAccount(void) {
    qDebug() << "apiLoginAccount ret :"
             << apiLoginAccount("user","pswd",nullptr);
}

void test_apiRandChinese(void) {

    char ch [256] = {};
    int i = 0;
    apiRandChinese(12,0, ch, &i);

    QString qs_data;
    qs_data = QString::fromLocal8Bit(ch,i);

    qDebug() << qs_data << i << ch;
}

void test_apiEncryptionCryptolalia(void) {
    QString str("请问以阿里贷款是否建立第");
    char ch_str[256] = {};
    qDebug() << "原数据 ：" << str;
    int ret = apiEncryptionCryptolalia(str.toUtf8().data(),0,ch_str,"123456789012");
    qDebug() << QString("加密后: %2  返回值 : %1")
                .arg(ret).arg(QString::fromUtf8(ch_str));

    char ch_str4[256] = {};
    ret = apiDecryptionCryptolalia(ch_str,0,
                                   ch_str4,"123456789012");
    qDebug() << QString("解密后: %2  返回值 : %1")
                .arg(ret).arg(QString::fromUtf8(ch_str4));
    return ;
}


void test_apiSignature(void) {
    char signa[128] = {};
    apiSignature("KyL1rdsH3j5qnYdpgWUjD8c2xLyGFJ5iRo15Bbzbi9vhTLTHFzjs",
                 "asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa21212d",signa);

    qDebug(signa);

    apiVerifySignature("15sKDurDH3CS3v6rKQJGSPDRvDWKvET8La",
                       signa,"asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa21212d");


}

void test_apiGeneratedPrvKey(void) {

    QString str("请问以阿里贷款是否建立第");
    char ch_str[256] = {};
    qDebug() << "原数据 ：" << str;
    int ret = apiEncryptionCryptolalia(str.toUtf8().data(),0,ch_str,"123456789012");
    qDebug() << QString("加密后: %2  返回值 : %1")
                .arg(ret).arg(QString::fromUtf8(ch_str));

    char ch_str2[256] = {};
    apiStdHashData(str.toUtf8().data(),(unsigned char*)ch_str2);
    qDebug() << ch_str2;

    char ch_str4[256] = {};
    ret = apiDecryptionCryptolalia(ch_str,0,
                                   ch_str4,"123456789012");
    qDebug() << QString("解密后: %2  返回值 : %1")
                .arg(ret).arg(QString::fromUtf8(ch_str4));

    QString cry = QString::fromUtf8(ch_str4);

    char ch_str5[256] = {};
    apiStdHashData(cry.toUtf8().data(),(unsigned char*)ch_str5);
    qDebug() << ch_str5;


}

void test_apiGeneratedMainPrvKey(void) {

    QString str("请问以阿里贷款是否建立第");
    char prvKey[256] = {};
//    apiGeneratedMainPrvKey(str.toUtf8().data(),
//                           "0/0",prvKey);

    qDebug() << apiGeneratedMainPrvKey(str.toUtf8().data(),
                                       "0/0",prvKey);
    qDebug() << prvKey;
    qDebug() << prvKey;
    qDebug() << prvKey;
}


void test_apiGeneratedChildPrvKey(void) {
    char pr[256] = {};
    apiGeneratedChildPrvKey("tprv8bbpt3kAC4bmHtvq9vinCC5M9gBjLZyStWX7ErdnuzSYUHsQYs8SkrLgrRtZewTgMMpFeRQRAtmzJcQhsDVoCzb32kZKBtkrPbuHiKhTYQs",
                            "0/0", pr);

    qDebug() << pr;
}
void test_apiGeneratedPrvKeyInfo(void) {
    char prvK[256] = {};
    char addr[256] = {};
    apiGeneratedPrvKeyInfo("tprv8bbpt3kAC4bmHtvq9vinCC5M9gBjLZyStWX7ErdnuzSYUHsQYs8SkrLgrRtZewTgMMpFeRQRAtmzJcQhsDVoCzb32kZKBtkrPbuHiKhTYQs",
                            Q_NULLPTR, Q_NULLPTR, prvK, addr);

    qDebug() << prvK << addr;
}

int main(void) {
//    std::cout << ucdata << std::endl;
//    test_apiGeneratedChildPrvKey();
    system("pause");

    return -1;
}
